//-----------------------------------------------------------------------
// <copyright file="MemberService.cs" company="FetCo">
//     Copyright (c) FetCo. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using FetCo.Framework;
using ADESSA.Entities;
using ADESSA.Data;
    
namespace ADESSA.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class MemberService
    {
        #region Member

        public static void CreateMember(Member member)
        {            
            try
            {
                MemberDAO memberDAO = new MemberDAO();
                memberDAO.CreateMember(member);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessCreateMemberException, ex);
            }
        }        

        public static void UpdateMember(Member member)
        {            
            try
            {
                MemberDAO memberDAO = new MemberDAO();
                memberDAO.UpdateMember(member);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessUpdateMemberException, ex);
            }
        }        

        public static void DeleteMember(long memberID)
        {            
            try
            {
                MemberDAO memberDAO = new MemberDAO();
                memberDAO.DeleteMember(memberID);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessDeleteMemberException, ex);
            }
        }
        
        public static Member GetMember(long memberID)
        {            
            try
            {
                MemberDAO memberDAO = new MemberDAO();
                return memberDAO.GetMember(memberID);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMemberException, ex);
            }
        }                

        public static MemberCollection GetMemberList(MemberColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                MemberDAO memberDAO = new MemberDAO();
                return memberDAO.GetMemberList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMemberListException, ex);
            }
        }        

        public static MemberCollection GetMemberList(MemberColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                MemberDAO memberDAO = new MemberDAO();
                return memberDAO.GetMemberList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMemberListException, ex);
            }
        }        

	    public static MemberCollection GetMemberListByParam(object orderBy, OrderDirection orderDirection,string where)
        {            
            try
            {
                MemberDAO memberDAO = new MemberDAO();
                return memberDAO.GetMemberListByParam(orderBy, orderDirection,where);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMemberListException, ex);
            }
        }        

        public static MemberCollection GetMemberListByParam(object orderBy, OrderDirection orderDirection, int page, int pageSize,string Criteria, out int totalRecords)
        {            
            try
            {
                MemberDAO memberDAO = new MemberDAO();
                return memberDAO.GetMemberListByParam(orderBy, orderDirection, page, pageSize,Criteria, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SR.BusinessGetMemberListException, ex);
            }
        }        

        #endregion
    }
}